package com.chenyi.leetcode.editor.cn;
/**
 * [27]移除元素
 * @author by chenyi
 * @className RemoveElement
 * @date 2022-06-20 22:02:50
 */
public class RemoveElement{
    public static void main(String[] args) {
        Solution solution = new RemoveElement().new Solution();
        System.out.println(solution.removeElement(new int[]{1, 1, 11, 2, 11, 2}, 2));
    }
    @SuppressWarnings("AlibabaCommentsMustBeJavadocFormat")
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int removeElement(int[] nums, int val) {
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != val) {
                nums[count++] = nums[i];
            }
        }
        return count;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}
